<?php

namespace App\Console\Commands;

use App\AdminAction;
use App\Lead;
use App\ProjectUser;
use App\User;
use Illuminate\Console\Command;

class Customer extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'xupengfei';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '瑞兴转移给我的转到其他账号下面';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
      $leads=Lead::where('owner_user_id',12)->get();
      foreach($leads as $item){
          /**
           * @var Lead $item
           */
          $userProject = new ProjectUser();
        //  $owner_user_id = $userProject->current(47);
          $owner_user_id = 15;
          $item->project_id=47;
          $item->owner_user_id=$owner_user_id;
          $item->save();
          $admin=new AdminAction();
          $admin->user_id=12;
          $admin->create_time=time();
          $admin->types='crm_leads';
          $admin->action_id=$item->leads_id;
          $admin->content='将线索转移给: '.User::find($owner_user_id)->realname ?? '';
          $admin->save();
      }
      $customer=  \App\Customer::where('owner_user_id',12)->get();
      foreach ($customer as $item){
          $userProject = new ProjectUser();
       //   $owner_user_id = $userProject->current(47);
          $owner_user_id = 15;
          $item->project_id=47;
          $item->owner_user_id=$owner_user_id;
          $item->save();
          $admin=new AdminAction();
          $admin->user_id=12;
          $admin->create_time=time();
          $admin->types='crm_customer';
          $admin->action_id=$item->customer_id;
          $admin->content='将线索转移给: '.User::find($owner_user_id)->realname ?? '';
          $admin->save();
      }


    }
}
